package common;

import asserts.Asserts;
import com.alibaba.fastjson.JSONObject;
import io.qameta.allure.Allure;
import io.qameta.allure.Attachment;

import java.util.List;
import java.util.Map;


/*
 *测试步骤，测试报告中展现
 */
public class TestStep {

    public static void requestAndRespondBody(String URL, JSONObject Body,String Respond){
        requestBody1(URL,Body);
        respondBody(Respond);

    }



    @Attachment("请求报文")
    public static  String requestBody(String URL, String body) {

        //格式化json串
        boolean prettyFormat = true; //格式化输出
        JSONObject jsonObject = JSONObject.parseObject(body);
        String str = JSONObject.toJSONString(jsonObject,prettyFormat);

        //报告展现请求报文

        return URL+"\n"+str;



    }

    public static void requestBody1(String URL, JSONObject body) {

        //格式化json串
        boolean prettyFormat = true; //格式化输出
        String str = JSONObject.toJSONString(body,prettyFormat);

        //报告展现请求报文
//        return URL+"\n"+str;
        String a=URL+"\n"+str;
        Allure.addAttachment("请求报文",a);
    }

//    @Attachment("请求报文")
//    public static String requestBody2(String URL, Map<String,String> body) {
//
//        //格式化json串
//        boolean prettyFormat = true; //格式化输出
//        String str =
//
//        //报告展现请求报文
//        return URL+"\n"+str;
//    }

    @Attachment("响应报文")
    public static void respondBody(String respond) {

        //格式化json串
        boolean prettyFormat = true; //格式化输出
        JSONObject jsonObject = JSONObject.parseObject(respond);
        String str = JSONObject.toJSONString(jsonObject,prettyFormat);

        //报告展现响应报文

        Allure.addAttachment("响应报文",str);
    }

    @Attachment("对比错误")
    public static void getassertInfolList(){
        String assertInfolList = Asserts.assertInfolList.toString();

        Allure.addAttachment("差异",assertInfolList);
//        return  assertInfolList;
    }




//    @Attachment("数据库断言结果")
//    public static StringBuffer databaseAssertResult(StringBuffer assertResult){
//        //报告展现数据库断言结果
//        return assertResult;
//    }
//
//    @Attachment("响应报文断言结果")
//    public static StringBuffer assertRespond(StringBuffer assertResult){
//        //报告展现数据库断言结果
//        return assertResult;
//    }
}